
***** PLEASE NOTE THAT THE ACT DATA USED IN "Is Voting Transformative? Expanding and Meta-Analyzing the Evidence" ARE PROPRIETARY AND CANNOT BE SHARED. 


********* Covariate Balance

use "ss19_midterm_election_students_only_for_John.dta", clear


*2018
 cd "" 

  rddensity running 
 
 foreach var in momed fathed rank female govclass   {
 
 egen `var'_std=std(`var'), mean(0) std(1)
 }

rdrobust momed running, c(0) all vce(cluster DOB_num) kernel(tri)
regsave Robust using "covariate_balance.dta", detail(all) replace addlabel(outcome, momed, bandwidth, CCT Optimal, year, 2018) table()

foreach var in  fathed rank female govclass  {

rdrobust `var' running, c(0) all vce(cluster DOB_num) kernel(tri)
regsave Robust using "covariate_balance.dta", detail(all) append addlabel(outcome, `var', bandwidth, CCT Optimal, year, 2018) table()

}

foreach var in momed fathed rank female govclass {

rdrobust `var' running, c(0) all vce(cluster DOB_num) kernel(tri) h(1751 1858) b(1751 1858)
regsave Robust using "covariate_balance.dta", detail(all) append addlabel(outcome, `var', bandwidth, Full, year, 2018) table()

}




*2016
use "nextgen.dta" , clear
  rddensity count 


foreach var in  white bg_mother_educ_lvl bg_father_educ_lvl  female grade_classification ///
hs_grad_year hs_gpa  hs_rank  t_cgis_tp_ushistory t_cgis_tp_worldhistory t_cgis_tp_otherhistory ///
t_cgis_tp_amgovernment t_cgis_tp_geography cgis_ge_ushistory  cgis_ge_worldhistory cgis_ge_otherhistory ///
cgis_ge_amgovernment cgis_ge_geography  hs_enroll_size took_adv_socs hs_yrs_socstd overall_gpa_0_4 ///
public_school rptd_stdscn_c rptd_stdscn_e rptd_stdscn_m rptd_stdscn_r {

 egen `var'_std=std(`var'), mean(0) std(1)

 }

foreach var in white bg_mother_educ_lvl bg_father_educ_lvl  female grade_classification ///
hs_grad_year hs_gpa  hs_rank  t_cgis_tp_ushistory t_cgis_tp_worldhistory t_cgis_tp_otherhistory ///
t_cgis_tp_amgovernment t_cgis_tp_geography cgis_ge_ushistory  cgis_ge_worldhistory cgis_ge_otherhistory ///
cgis_ge_amgovernment cgis_ge_geography  hs_enroll_size took_adv_socs hs_yrs_socstd overall_gpa_0_4 ///
public_school rptd_stdscn_c rptd_stdscn_e rptd_stdscn_m rptd_stdscn_r {
	
	rdrobust `var'_std count, c(0) all vce(cluster count) // survey taking
	regsave Robust using "covariate_balance.dta", detail(all) append addlabel(outcome, `var'_std, bandwidth, CCT Optimal, year, 2016) table()

	}
	
	
foreach var in white bg_mother_educ_lvl bg_father_educ_lvl  female grade_classification ///
hs_grad_year hs_gpa  hs_rank  t_cgis_tp_ushistory t_cgis_tp_worldhistory t_cgis_tp_otherhistory ///
t_cgis_tp_amgovernment t_cgis_tp_geography cgis_ge_ushistory  cgis_ge_worldhistory cgis_ge_otherhistory ///
cgis_ge_amgovernment cgis_ge_geography  hs_enroll_size took_adv_socs hs_yrs_socstd overall_gpa_0_4 ///
public_school rptd_stdscn_c rptd_stdscn_e rptd_stdscn_m rptd_stdscn_r {
	
	rdrobust `var'_std count, c(0) all vce(cluster count) h(1751 1858) b(1751 1858) // survey taking
	regsave Robust using "covariate_balance.dta", detail(all) append addlabel(outcome, `var'_std, bandwidth, Full, year, 2016) table()

	}	

	
use covariate_balance.dta, clear	
	
replace outcome="ACT Read (2016)" if outcome=="rptd_stdscn_r_std"	
replace outcome="ACT Math (2016)" if outcome=="rptd_stdscn_m_std"	
replace outcome="ACT English (2016)" if outcome=="rptd_stdscn_e_std"	
replace outcome="ACT Total (2016)" if outcome=="rptd_stdscn_c_std"	
replace outcome="In Public School (2016)" if outcome=="public_school_std"	
replace outcome="GPA (2016)" if outcome=="overall_gpa_0_4_std"	
replace outcome="Num SS Courses (2016)" if outcome=="hs_yrs_socstd_std"	
replace outcome="Took Adv. SS (2016)" if outcome=="took_adv_socs_std"	
replace outcome="HS Enroll (2016)" if outcome=="hs_enroll_size_std"	
replace outcome="Grades Geo (2016)" if outcome=="cgis_ge_geography_std"	
replace outcome="Grades Am. Govt. (2016)" if outcome=="cgis_ge_amgovernment_std"	
replace outcome="Grades Other History (2016)" if outcome=="cgis_ge_otherhistory_std"	
replace outcome="Grades Intl History (2016)" if outcome=="cgis_ge_worldhistory_std"	
replace outcome="Grades U.S. History (2016)" if outcome=="cgis_ge_ushistory_std"	
replace outcome="Took Geo (2016)" if outcome=="t_cgis_tp_geography_std"	
replace outcome="Took Am. Govt. (2016)" if outcome=="t_cgis_tp_amgovernment_std"	
replace outcome="Took Other History (2016)" if outcome=="t_cgis_tp_otherhistory_std"	
replace outcome="Took Intl History (2016)" if outcome=="t_cgis_tp_worldhistory_std"	
replace outcome="Took U.S. History (2016)" if outcome=="t_cgis_tp_ushistory_std"	
replace outcome="HS Rank (2016)" if outcome=="hs_rank_std"	
replace outcome="HS GPA (2016)" if outcome=="hs_gpa_std"	
replace outcome="HS Grad Year (2016)" if outcome=="hs_grad_year_std"	
replace outcome="Grade (2016)" if outcome=="grade_classification_std"	
replace outcome="Female (2016)" if outcome=="female_std"	
replace outcome="Father Ed (2016)" if outcome=="bg_father_educ_lvl_std"	
replace outcome="Mother Ed (2016)" if outcome=="bg_mother_educ_lvl_std"	
replace outcome="White (2016)" if outcome=="white_std"	
replace outcome="Govt Class (2018)" if outcome=="govclass"	
replace outcome="Female (2018)" if outcome=="female"	
replace outcome="HS Rank (2018)" if outcome=="rank"	
replace outcome="Father Ed (2018)" if outcome=="fathed"	
replace outcome="Mother Ed (2018)" if outcome=="momed"	
	

capture drop effective_N
gen effective_N=N_h_l + N_h_r

gen significant=1 if coef/stderr > abs(1.96)
replace significant=0 if significant==.

gen bonf_significant=1 if coef/stderr > abs(3.3)
replace bonf_significant=0 if bonf_significant==.

tab significant
tab bonf_significant

sum coef, d

saveold "covariate_balance.dta", replace version(12)	

	

*********************** Regression Discontinuity EFFECTS ON OUTCOMES STARTS HERE

use "ss19_midterm_election_students_only_for_John.dta", clear

rdrobust voted_0_1 running, c(0) all vce(cluster DOB_num) kernel(tri)
rdrobust voted_0_1_clean running, c(0) all vce(cluster DOB_num) kernel(tri)

cd "" 

sum running


*Optimal Bandwidth
rdrobust voted_0_1_clean_std running, c(0) all vce(cluster DOB_num) kernel(tri)
regsave Robust using "Transformative_voting_scales.dta", detail(all) replace addlabel(outcome, Voting, bandwidth, CCT Optimal) table()

foreach var in interest_scale_std civicduty_std polknow_std  ideology_std fakenews_scale_std {

rdrobust `var'  running, c(0) all vce(cluster DOB_num) kernel(tri)
regsave Robust using "Transformative_voting_scales.dta", detail(all) append addlabel(outcome, `var', bandwidth, CCT Optimal) table()

}

*Full BW
rdrobust voted_0_1_clean_std running, c(0) all vce(cluster DOB_num) kernel(tri) h(1858) b(1858)
regsave Robust using "Transformative_voting_scales.dta", detail(all) append addlabel(outcome, Voting, bandwidth, Full) table()


foreach var in interest_scale_std civicduty_std polknow_std  ideology_std fakenews_scale_std {

rdrobust `var'  running, c(0) all vce(cluster DOB_num) kernel(tri)  h(1858) b(1858)
regsave Robust using "Transformative_voting_scales.dta", detail(all) append addlabel(outcome, `var', bandwidth, Full) table()

}



use "Transformative_voting_scales.dta", clear

replace outcome="Exposure to Fake News" if outcome=="fakenews_scale_std"
replace outcome="Liberal Ideology" if outcome=="ideology_std"
replace outcome="Political Knowledge" if outcome=="polknow_std"
replace outcome="Political Interest" if outcome=="interest_scale_std"
replace outcome="Civic Duty" if outcome=="civicduty_std"
replace outcome="Voter Turnout" if outcome=="Voting"

capture drop num
gen num=_n

replace num = 1 if outcome=="Exposure to Fake News"
replace num = 2 if outcome=="Liberal Ideology"
replace num = 3 if outcome=="Political Knowledge"
replace num = 4 if outcome=="Civic Duty"
replace num = 5 if outcome=="Political Interest"
replace num = 6 if outcome=="Voter Turnout"

capture drop effective_N
gen effective_N=N_h_l + N_h_r

gsort - num  - outcome - bandwidth // for the Ns in the figure notes

sum coef, d

capture drop coef_label coef_label2 
gen coef_label=coef
replace coef_label=round(coef_label, .01)
gen double coef_label2=coef_label
replace coef_label2=round(coef_label2, .01)

capture drop se_label se_label2
gen se_label=stderr
replace se_label=round(stderr, .01)
gen double se_label2=se_label
replace se_label2=round(se_label2, .01)

capture drop beta comma se label_all
gen beta="b="
gen comma=", "
gen se="se="

egen label_all=concat(beta coef_label2 comma se se_label2)

replace num = 2 in 11
replace num = 3 in 10
replace num = 4 in 9
replace num = 5 in 8
replace num = 6 in 7
replace num = 7 in 6
replace num = 8 in 5
replace num = 9 in 4
replace num = 10 in 3
replace num = 11 in 2
replace num = 12 in 1

replace outcome = "Voter Turnout, Full" in 1
replace outcome = "Voter Turnout, Optimal" in 2
replace outcome = "Political Interest, Full" in 3
replace outcome = "Political Interest, Optimal" in 4
replace outcome = "Civic Duty, Full" in 5
replace outcome = "Civic Duty, Optimal" in 6
replace outcome = "Political Knowledge, Full" in 7
replace outcome = "Political Knowledge, Optimal" in 8
replace outcome = "Liberal Ideology, Full" in 9
replace outcome = "Liberal Ideology, Optimal" in 10
replace outcome = "Exposure to Fake News, Full" in 11
replace outcome = "Exposure to Fake News, Optimal" in 12

saveold "Transformative_voting_scales.dta", replace version(12)


***********IV estimates

use "ss19_midterm_election_students_only_for_John.dta", clear

*gen eligible=1 if running>=0
*replace eligible=0 if running<0

*gen running2=running*running
*gen running3=running*running*running

*foreach var in interest_scale_std civicduty_std polknow_std social_scale_std ideology_std fakenews_scale_std {
*ivregress 2sls `var' (voted_0_1_clean=eligible running running2 running3) running running2 running3 if running<=365 & running>=-365, cluster(running)
*}


rdrobust interest_scale_std running, c(0) all vce(cluster DOB_num) kernel(tri) fuzzy(voted_0_1_clean)
regsave Robust using "IV_estimates.dta", detail(all) replace addlabel(outcome, interest_scale_std, bandwidth, Optimal) table()

foreach var in  civicduty_std polknow_std  ideology_std fakenews_scale_std {
rdrobust `var' running, c(0) all vce(cluster DOB_num) kernel(tri) fuzzy(voted_0_1_clean)
regsave Robust using "IV_estimates.dta", detail(all) append addlabel(outcome, `var', bandwidth, Optimal) table()
}

foreach var in  interest_scale_std civicduty_std polknow_std ideology_std fakenews_scale_std {
rdrobust `var' running, c(0) all vce(cluster DOB_num) kernel(tri) fuzzy(voted_0_1_clean) h(1858) b(1858)
regsave Robust using "IV_estimates.dta", detail(all) append addlabel(outcome, `var', bandwidth, Full) table()
}


use "IV_estimates.dta", clear

replace outcome="Exposure to Fake News" if outcome=="fakenews_scale_std"
replace outcome="Liberal Ideology" if outcome=="ideology_std"
replace outcome="Political Knowledge" if outcome=="polknow_std"
replace outcome="Political Interest" if outcome=="interest_scale_std"
replace outcome="Civic Duty" if outcome=="civicduty_std"

capture drop t significant significant_90 num effective_N
gen t=coef/stderr

gen significant=1 if t>1.96 | t<-1.96
replace significant=0 if t<=1.96 & t>=-1.96

tab significant // 0%

gen significant_90=1 if t>1.64 | t<-1.64
replace significant_90=0 if t<=1.64 & t>=-1.64

tab significant_90 // 7.69%

gen num=1 if bandwidth=="Full"
replace num=2 if bandwidth=="Optimal"

capture drop effective_N
gen effective_N=N_h_l + N_h_r


saveold "IV_estimates.dta", version(12) replace

********* 2018 interest rescaled

sum interest_scale_std, d

 gen interest_scale_std_4=1 if interest_scale_std<=.6666667 
replace interest_scale_std_4=2 if interest_scale_std>.6666667  & interest_scale_std <= .7777778  
replace interest_scale_std_4=3 if interest_scale_std> .7777778   & interest_scale_std<= .8888889  
replace interest_scale_std_4=4 if interest_scale_std> .8888889   & interest_scale_std~=.

rdrobust interest_scale_std_4  running, c(0) all vce(cluster running) kernel(tri)

********* 2016 and 2018

 *2016
cd "" 

insheet using "nextgen.csv",  clear

foreach var in q8 q9 q10_1 q10_2 q10_3 q10_4 q10_5 q10_6 q10_7 q10_8 q10_9 q10_10 q10_11 q10_11_text q10_12 q12 q13 q14 q15 q17_1 q17_2 q17_3 q17_4 q17_5 q17_6 q17_7 q18 q19 q20 q21 q25 q22_1 q22_2 q22_3 q22_4 q22_5 q22_6 q22_7 q22_8 q22_9 q22_10 q22_11 q22_12 q22_12_text q24 q23 {
capture replace `var' = . if `var'==-99
}

*Political Knowledge


factor q10_1 q10_2 q10_3 q10_4 q10_5 q10_6 q10_7 q10_8 q10_9 q10_10 q10_11 q12, factor(1)
predict political_knowledge
egen political_knowledge_std=std(political_knowledge), mean(0) std(1)

*Social Awareness
factor q17_4 q17_5 q17_6 q17_7
predict social_awareness
egen social_awareness_std=std(social_awareness), mean(0) std(1)

*Political Interest
alpha 	q8  q13 q19 q20 q21
factor q8  q13 q19 q20 q21
predict political_interest
egen political_interest_std=std(political_interest), mean(0) std(1)

keep count social_awareness_std political_interest_std  political_knowledge_std

rename count running

*Optimal Bandwidth
rdrobust social_awareness_std running, c(0) all vce(cluster running) kernel(tri)
regsave Robust using "Transformative_voting_2016.dta", detail(all) replace addlabel(outcome, Social Awareness, bandwidth, CCT Optimal) table()

foreach var in political_interest_std  political_knowledge_std {

rdrobust `var'  running, c(0) all vce(cluster running) kernel(tri)
regsave Robust using "Transformative_voting_2016.dta", detail(all) append addlabel(outcome, `var', bandwidth, CCT Optimal) table()

}

*Full BW
foreach var in social_awareness_std political_interest_std  political_knowledge_std {

rdrobust `var'  running, c(0) all vce(cluster running) kernel(tri)  h(365) b(365)
regsave Robust using "Transformative_voting_2016.dta", detail(all) append addlabel(outcome, `var', bandwidth, Full) table()

}

save "Pared Down 2016 Data.dta", replace


*2016 RD ouput

use "Transformative_voting_2016.dta", clear

replace outcome="Social Awareness" if outcome=="social_awareness_std"
replace outcome="Political Interest" if outcome=="political_interest_std"
replace outcome="Political Knowledge" if outcome=="political_knowledge_std"

capture drop num
gen num=_n

capture drop effective_N
gen effective_N=N_h_l + N_h_r

sum coef, d


capture drop coef_label coef_label2 
gen coef_label=coef
replace coef_label=round(coef_label, .01)
gen double coef_label2=coef_label
replace coef_label2=round(coef_label2, .01)

capture drop se_label se_label2
gen se_label=stderr
replace se_label=round(stderr, .01)
gen double se_label2=se_label
replace se_label2=round(se_label2, .01)

capture drop beta comma se label_all
gen beta="b="
gen comma=", "
gen se="se="

egen label_all=concat(beta coef_label2 comma se se_label2)

replace outcome = "Political Knowledge, Full" in 1
replace outcome = "Political Interest, Full" in 2
replace outcome = "Social Awareness, Full" in 3
replace outcome = "Political Knowledge, Optimal" in 4
replace outcome = "Political Interest, Optimal" in 5
replace outcome = "Social Awareness, Optimal" in 6

replace num = 2 in 4
replace num = 3 in 2
replace num = 4 in 5
replace num = 5 in 3

saveold "Transformative_voting_2016.dta", version(12) replace



*2016--pared down
cd "" 

insheet using "nextgen.csv",  clear

foreach var in q8 q9 q10_1 q10_2 q10_3 q10_4 q10_5 q10_6 q10_7 q10_8 q10_9 q10_10 q10_11 q10_11_text q10_12 q12 q13 q14 q15 q17_1 q17_2 q17_3 q17_4 q17_5 q17_6 q17_7 q18 q19 q20 q21 q25 q22_1 q22_2 q22_3 q22_4 q22_5 q22_6 q22_7 q22_8 q22_9 q22_10 q22_11 q22_12 q22_12_text q24 q23 {
capture replace `var' = . if `var'==-99
}
egen knowledge_prop=rowmean(q10_1 q10_2 q10_3 q10_4 q10_5 q10_6 q10_7 q10_8 q10_9 q10_10 q10_11)
 egen knowledge_prop_std=std(knowledge_prop), mean(0) std(1)

 rename count running
  
 *q8 // follow news
*q13 // thought to the election
*q19 // discuss politics family
*q20 // discuss politics  school
*q21 // discuss politics friends

factor q8 q13 q19 q20 q21
predict political_interest
egen political_interest_std=std(political_interest), mean(0) std(1)

keep running knowledge_prop_std political_interest_std

gen year=2016

drop if running==.
drop if knowledge_prop_std==. & political_interest_std==. 

save "pared_2016_for_both_waves.dta", replace


 *2018
 use "ss19_midterm_election_students_only_for_John.dta", clear
 
 egen knowledge_prop=rowmean(Newspaper  Network_News Cable_News Radio   News_Magazines Social_Media Other_Source)
 egen knowledge_prop_std=std(knowledge_prop), mean(0) std(1)
 
* q4 // follow news
* q2 // thought to the election
* q13 // discuss politics family
* q14 // discuss politics  school
* q15 // discuss politics friends

factor polinterest3 polinterest1 polsoc1 polsoc2 polsoc3
predict political_interest
egen political_interest_std=std(political_interest), mean(0) std(1)
 
keep running knowledge_prop_std political_interest_std
 
 gen year=2018
 
 drop if running==.
drop if knowledge_prop_std==. & political_interest_std==. 

 save "pared_2018_for_both_waves.dta", replace

 
 
 *Both
 use "pared_2016_for_both_waves.dta", clear
 append using "pared_2018_for_both_waves.dta"
 

cd ""


rdrobust knowledge_prop_std running, c(0) all vce(cluster running) kernel(tri) 
regsave Robust using "Transformative_voting_both_years.dta", detail(all) replace addlabel(outcome, Political Knowledge, bandwidth, CCT Optimal) table()

foreach var in  political_interest_std {

rdrobust `var'  running, c(0) all vce(cluster running) kernel(tri)
regsave Robust using "Transformative_voting_both_years.dta", detail(all) append addlabel(outcome, `var', bandwidth, CCT Optimal) table()

}


foreach var in knowledge_prop_std political_interest_std {

rdrobust `var'  running, c(0) all vce(cluster running) kernel(tri) h(365 365) b(365 365) // doing this because 2016's full BW is much narrower
regsave Robust using "Transformative_voting_both_years.dta", detail(all) append addlabel(outcome, `var', bandwidth, Full) table()

}



use "Transformative_voting_both_years.dta", clear

replace outcome="Political Knowledge" if outcome=="knowledge_prop_std"
replace outcome="Political Interest" if outcome=="political_interest_std"

capture drop num
gen num=_n

capture drop effective_N
gen effective_N=N_h_l + N_h_r

sum coef, d


capture drop coef_label coef_label2 
gen coef_label=coef
replace coef_label=round(coef_label, .01)
gen double coef_label2=coef_label
replace coef_label2=round(coef_label2, .01)

capture drop se_label se_label2
gen se_label=stderr
replace se_label=round(stderr, .01)
gen double se_label2=se_label
replace se_label2=round(se_label2, .01)

capture drop beta comma se label_all
gen beta="b="
gen comma=", "
gen se="se="

egen label_all=concat(beta coef_label2 comma se se_label2)

replace outcome = "Political Interest, Full" in 1
replace outcome = "Political Knowledge, Full" in 2
replace outcome = "Political Interest, Optimal" in 3
replace outcome = "Political Knowledge, Optimal" in 4

replace num = 2 in 3
replace num = 3 in 2

saveold "Transformative_voting_both_years.dta", replace version(12)

********* Heterogeneities

use "ss19_midterm_election_students_only_for_John.dta", clear

cd ""

rdrobust voted_0_1_clean_std running if momed>=5, c(0) all vce(cluster running) kernel(tri)
regsave Robust using "Transformative_voting_hets.dta", detail(all) replace addlabel(outcome, voted_0_1_clean_std, SESHet, High) table()
rdrobust voted_0_1_clean_std running if momed<5, c(0) all vce(cluster running) kernel(tri)
regsave Robust using "Transformative_voting_hets.dta", detail(all) append addlabel(outcome, voted_0_1_clean_std, SESHet, Low) table()

foreach var in interest_scale_std civicduty_std polknow_std  ideology_std fakenews_scale_std {
rdrobust `var' running if momed>=5, c(0) all vce(cluster running) kernel(tri)
regsave Robust using "Transformative_voting_hets.dta", detail(all) append addlabel(outcome, `var', SESHet, High) table()
rdrobust `var' running if momed<5, c(0) all vce(cluster running) kernel(tri)
regsave Robust using "Transformative_voting_hets.dta", detail(all) append addlabel(outcome, `var', SESHet, Low) table()
}

use "Transformative_voting_hets.dta", clear

replace outcome="Exposure to Fake News" if outcome=="fakenews_scale_std"
replace outcome="Liberal Ideology" if outcome=="ideology_std"
replace outcome="Political Knowledge" if outcome=="polknow_std"
replace outcome="Political Interest" if outcome=="interest_scale_std"
replace outcome="Civic Duty" if outcome=="civicduty_std"
replace outcome="Voter Turnout" if outcome=="voted_0_1_clean_std"


capture drop num
gen num=_n

capture drop effective_N
gen effective_N=N_h_l + N_h_r

gsort - num -  SESHet  // for the Ns in the figure notes


saveold "Transformative_voting_hets.dta", replace version(12)

*FULL BW
use "ss19_midterm_election_students_only_for_John.dta", clear


rdrobust voted_0_1_clean_std running if momed>=5, c(0) all vce(cluster running) kernel(tri) h(1751 1858) b(1751 1858)
regsave Robust using "Transformative_voting_hets_full_bw.dta", detail(all) replace addlabel(outcome, voted_0_1_clean_std, SESHet, High) table()
rdrobust voted_0_1_clean_std running if momed<5, c(0) all vce(cluster running) kernel(tri) h(1751 1858) b(1751 1858)
regsave Robust using "Transformative_voting_hets_full_bw.dta", detail(all) append addlabel(outcome, voted_0_1_clean_std, SESHet, Low) table()

foreach var in  interest_scale_std civicduty_std polknow_std social_scale_std ideology_std fakenews_scale_std {
rdrobust `var' running if momed>=5, c(0) all vce(cluster running) kernel(tri) h(1751 1858) b(1751 1858)
regsave Robust using "Transformative_voting_hets_full_bw.dta", detail(all) append addlabel(outcome, `var', SESHet, High) table()
rdrobust `var' running if momed<5, c(0) all vce(cluster running) kernel(tri) h(1751 1858) b(1751 1858)
regsave Robust using "Transformative_voting_hets_full_bw.dta", detail(all) append addlabel(outcome, `var', SESHet, Low) table()
}

use "Transformative_voting_hets_full_bw.dta", clear

replace outcome="Exposure to Fake News" if outcome=="fakenews_scale_std"
replace outcome="Liberal Ideology" if outcome=="ideology_std"
replace outcome="Social Awareness" if outcome=="social_scale_std"
replace outcome="Political Knowledge" if outcome=="polknow_std"
replace outcome="Political Interest" if outcome=="interest_scale_std"
replace outcome="Civic Duty" if outcome=="civicduty_std"
replace outcome="Voter Turnout" if outcome=="voted_0_1_clean_std"

capture drop num
gen num=_n

capture drop effective_N
gen effective_N=N_h_l + N_h_r

gsort - num  - outcome - SESHet // for the Ns in the figure notes


saveold "Transformative_voting_hets_full_bw.dta", replace version(12)



use "Transformative_voting_hets_full_bw.dta", clear
append using "Transformative_voting_hets.dta"


sum coef, d

********* OTHER HETS

use "ss19_midterm_election_students_only_for_John.dta", clear

gen minority=1 if BG_RACE_ETHNIC ~=3 & BG_RACE_ETHNIC ~=.
replace minority=0 if BG_RACE_ETHNIC ==3

gen conservative=1 if ideology==1 | ideology==2
replace conservative=0 if ideology==3 | ideology==4 | ideology==5

gen moderate=1 if ideology==3
replace moderate=0 if ideology==1 | ideology==4 | ideology==5 | ideology==2

gen liberal=1 if  ideology==4 | ideology==5 
replace liberal=0 if ideology==3 | ideology==1 | ideology==2

sum rank female govclass minority, d

cd ""

rdrobust interest_scale_std running if rank<=1, c(0) all vce(cluster running) kernel(tri)
regsave Robust using "Transformative_voting_hets_other.dta", detail(all) replace addlabel(outcome, interest_scale_std, moderator, High Rank in School, condition, Yes) table()
rdrobust interest_scale_std running if rank>=2 & rank~=., c(0) all vce(cluster running) kernel(tri)
regsave Robust using "Transformative_voting_hets_other.dta", detail(all) append addlabel(outcome, interest_scale_std, moderator, High Rank in School, condition, No) table()

foreach var in  civicduty_std polknow_std  ideology_std fakenews_scale_std {
rdrobust `var' running if rank<=1, c(0) all vce(cluster running) kernel(tri)
regsave Robust using "Transformative_voting_hets_other.dta", detail(all) append addlabel(outcome, `var', moderator, High Rank in School, condition, Yes) table()
rdrobust `var' running if rank>=2, c(0) all vce(cluster running) kernel(tri)
regsave Robust using "Transformative_voting_hets_other.dta", detail(all) append addlabel(outcome, `var', moderator, High Rank in School, condition, No) table()
}

foreach var in interest_scale_std civicduty_std polknow_std  ideology_std fakenews_scale_std {
rdrobust `var' running if female==1, c(0) all vce(cluster running) kernel(tri)
regsave Robust using "Transformative_voting_hets_other.dta", detail(all) append addlabel(outcome, `var', moderator, Female, condition, Yes) table()
rdrobust `var' running if female==0, c(0) all vce(cluster running) kernel(tri)
regsave Robust using "Transformative_voting_hets_other.dta", detail(all) append addlabel(outcome, `var', moderator, Female, condition, No) table()
}

foreach var in interest_scale_std civicduty_std polknow_std  ideology_std fakenews_scale_std {
rdrobust `var' running if govclass==1, c(0) all vce(cluster running) kernel(tri)
regsave Robust using "Transformative_voting_hets_other.dta", detail(all) append addlabel(outcome, `var', moderator, Government Class in HS, condition, Yes) table()
rdrobust `var' running if govclass==0, c(0) all vce(cluster running) kernel(tri)
regsave Robust using "Transformative_voting_hets_other.dta", detail(all) append addlabel(outcome, `var', moderator, Government Class in HS, condition, No) table()
}

foreach var in interest_scale_std civicduty_std polknow_std  ideology_std fakenews_scale_std {
rdrobust `var' running if minority==1, c(0) all vce(cluster running) kernel(tri)
regsave Robust using "Transformative_voting_hets_other.dta", detail(all) append addlabel(outcome, `var', moderator, Minority, condition, Yes) table()
rdrobust `var' running if minority==0, c(0) all vce(cluster running) kernel(tri)
regsave Robust using "Transformative_voting_hets_other.dta", detail(all) append addlabel(outcome, `var', moderator, Minority, condition, No) table()
}

foreach var in interest_scale_std civicduty_std polknow_std  fakenews_scale_std {
rdrobust `var' running if conservative==1, c(0) all vce(cluster running) kernel(tri)
regsave Robust using "Transformative_voting_hets_other.dta", detail(all) append addlabel(outcome, `var', moderator, Ideology: Conservative, condition, Yes) table()
rdrobust `var' running if conservative==0, c(0) all vce(cluster running) kernel(tri)
regsave Robust using "Transformative_voting_hets_other.dta", detail(all) append addlabel(outcome, `var', moderator, Ideology: Conservative, condition, No) table()
rdrobust `var' running if moderate==1, c(0) all vce(cluster running) kernel(tri)
regsave Robust using "Transformative_voting_hets_other.dta", detail(all) append addlabel(outcome, `var', moderator, Ideology: Moderate, condition, Yes) table()
rdrobust `var' running if moderate==0, c(0) all vce(cluster running) kernel(tri)
regsave Robust using "Transformative_voting_hets_other.dta", detail(all) append addlabel(outcome, `var', moderator, Ideology: Moderate, condition, No) table()
rdrobust `var' running if liberal==1, c(0) all vce(cluster running) kernel(tri)
regsave Robust using "Transformative_voting_hets_other.dta", detail(all) append addlabel(outcome, `var', moderator, Ideology: Liberal, condition, Yes) table()
rdrobust `var' running if liberal==1, c(0) all vce(cluster running) kernel(tri)
regsave Robust using "Transformative_voting_hets_other.dta", detail(all) append addlabel(outcome, `var', moderator, Ideology: Liberal, condition, No) table()
}

use "Transformative_voting_hets_other.dta", clear

replace outcome="Exposure to Fake News" if outcome=="fakenews_scale_std"
replace outcome="Liberal Ideology" if outcome=="ideology_std"
replace outcome="Political Knowledge" if outcome=="polknow_std"
replace outcome="Political Interest" if outcome=="interest_scale_std"
replace outcome="Civic Duty" if outcome=="civicduty_std"

gen t=coef/stderr

gen significant=1 if t>1.96 | t<-1.96
replace significant=0 if t<=1.96 & t>=-1.96

tab significant // 0%

gen significant_90=1 if t>1.64 | t<-1.64
replace significant_90=0 if t<=1.64 & t>=-1.64

tab significant_90 // 7.69%

capture drop num
gen num=_n

capture drop effective_N
gen effective_N=N_h_l + N_h_r

gen lb95= coef-1.96*stderr
gen ub95= coef+1.96*stderr

gen diff_36_perc_sd=1 if lb95>=-0.36 & ub95<=0.36
replace diff_36_perc_sd=0 if lb95<-0.36 | ub95>0.36

saveold "Transformative_voting_hets_other.dta", replace version(12)


********* Composite Scale
use "ss19_midterm_election_students_only_for_John.dta", clear

factor interest_scale_std civicduty_std polknow_std 
predict social_capital
egen social_capital_std=std(social_capital), mean(0) std(1)

rdrobust social_capital_std running , c(0) all vce(cluster running) kernel(tri)


********* APPENDIX MATERIALS

*Individual inputs
foreach var in polinterest1_std polinterest2_std polinterest3_std ideology_std polknow_std civicduty_std economy_std getting_job_std terrorism_std US_standing_std immigration_std race_issues_std college_ed_afford_std personal_safety_std climate_change_std gender_issues_std LGBTQ_rights_std other_country_perceptions_std gun_violence_std other_issue_std polsoc1_std polsoc2_std polsoc3_std Newspaper_std Network_News_std Cable_News_std Radio_std News_Magazines_std Social_Media_std Other_Source_std No_Source_std BBC_std Blaze_std Breitbart_std CNN_std FOX_std Huffington_Post_std INFOWARS_std Natural_News_std New_York_Times_std NPR_std US_Uncut_std USA_Today_std The_Atlantic_std The_Hill_std Washington_Post_std Other_online_source_std No_online_source_std fakenews_std fakenews2_std newscount_std social_scale_std total_interest_scale_std interest_scale_std lib_ideology_std fakenews_scale_std maga_scale_std sociability_std number_missing_std {
rdrobust `var' running, c(0) all vce(cluster DOB_num) kernel(tri)
regsave Robust using "Transformative_voting.dta", detail(all) append addlabel(outcome, `var') table()
}

rdrobust vote2_std running, c(0) all vce(cluster DOB_num) kernel(tri) h(1751 1858) b(1751 1858)
regsave Robust using "Transformative_voting_robust.dta", detail(all) replace addlabel(outcome, vote2) table()

foreach var in polinterest1_std polinterest2_std polinterest3_std ideology_std polknow_std civicduty_std economy_std getting_job_std terrorism_std US_standing_std immigration_std race_issues_std college_ed_afford_std personal_safety_std climate_change_std gender_issues_std LGBTQ_rights_std other_country_perceptions_std gun_violence_std other_issue_std polsoc1_std polsoc2_std polsoc3_std Newspaper_std Network_News_std Cable_News_std Radio_std News_Magazines_std Social_Media_std Other_Source_std No_Source_std BBC_std Blaze_std Breitbart_std CNN_std FOX_std Huffington_Post_std INFOWARS_std Natural_News_std New_York_Times_std NPR_std US_Uncut_std USA_Today_std The_Atlantic_std The_Hill_std Washington_Post_std Other_online_source_std No_online_source_std fakenews_std fakenews2_std newscount_std social_scale_std total_interest_scale_std interest_scale_std lib_ideology_std fakenews_scale_std maga_scale_std sociability_std number_missing_std {
rdrobust `var' running, c(0) all vce(cluster DOB_num) kernel(tri) h(1751 1858) b(1751 1858)
regsave Robust using "Transformative_voting_robust.dta", detail(all) append addlabel(outcome, `var') table()
}

rdrobust registered_std running, c(0) all vce(cluster DOB_num) kernel(tri)

save "Transformative Voting Final.dta"
